// components/home-finished/home-finished.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    date: '',
    show: false,
    timeshow: false,
    id:0,
    counts:false,
    title:'开始时间',
    isBut:true,
    butName:'筛选',
    value:'',
    show:false,
    startTime:'开始时间',
    endTime:'结束时间',
    currentDate: new Date().getTime(),
    minDate: new Date().getTime(),
    formatter(type, value) {
      if (type === 'year') {
        return `${value}年`;
      }
      if (type === 'month') {
        return `${value}月`;
      }
      if (type === 'day') {
        return `${value}日`;
      }
      return value;
    },

  },
 
  /**
   * 组件的方法列表
   */
  methods: {
    onDisplay() {
      this.setData({ show: true });
    },
    onClose() {
      this.setData({ show: false });
    },
    ontimeDisplay() {
      this.setData({ timeshow: true });
    },
    ontimeClose() {
      this.setData({ timeshow: false });
    },
    formatDate(date) {
      date = new Date(date);
      return `${date.getFullYear()}.${date.getMonth() + 1}.${date.getDate()}`;
    },
    onConfirm(event) {
      this.setData({
        show: false,
        date: this.formatDate(event.detail),
      });
    },
  },
  timeVal(e){
    if(this.data.title === '开始时间'){
      const startTime = wx.formatDate(e.detail)
      this.setData({startTime: startTime})
     
    }else{
      const endTime = wx.$formatDate(e.detail)
      this.setData({endTime: endTime ,isBut:!this.data.isBut , butName:'重置'})
     this.getTasks()
    }
    this.setData({ timeshow : !this.data.timeshow })
  },
  isShow(e){
    
    if(e.mark.id === 'start'){
      this.setData({ title : '开始时间' })
    }else{
      this.setData({ title : '结束时间' })
    }

  this.setData({ show : !this.data.show })
},
reset(){
  console.log('重置');
  this.setData({
    counts:false,
    isBut:true,
    butName:'筛选',
    startTime:'开始时间',
    endTime:'结束时间',
  })
},

})
